package org.irenty;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlPage;

public class ScreenScrapper {
    private static final Logger LOGGER = LoggerFactory.getLogger(ScreenScrapper.class);

    public HtmlPage getPage(String url) {
        final WebClient webClient = new WebClient();
        HtmlPage page = null;
        try {
            page = webClient.getPage(url);
        } catch (Exception e) {
            LOGGER.error("Can't get the page for url: " + url, e);
            throw new RuntimeException(e);
        } finally {
            webClient.closeAllWindows();
        }
        return page;
    }
}
